home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MACD 5
/
MACD 5.bin
/
workbench
/
tools
/
czesc_2
/
lettermatcher
/
lettermatcher.doc
< prev
next >
Wrap
Text File
|
1993-08-11
|
10KB
|
251 lines
Tired of these old
LLLL OOOOOOOOOO GGGGGGGGGG OOOOOOOOOO SSSSSSSSSS
LLLL OOOO OOOO GGGG GGGG OOOO OOOO SSSS SSSS
LLLL OOOO OOOO GGGG GGGG OOOO OOOO SSSS
LLLL OOOO OOOO GGGG OOOO OOOO SSSSSSSSSS
LLLL OOOO OOOO GGGG GGGGGG OOOO OOOO SSSS
LLLL OOOO OOOO GGGG GGGG OOOO OOOO SSSS SSSS
LLLL OOOO OOOO GGGG GGGG OOOO OOOO SSSS SSSS
LLLLLLLLLL OOOOOOOOOO GGGGGGGGGG OOOOOOOOOO SSSSSSSSSS
????
If so, then ...
_wæ*°"9æ,
gØ° â#
_dH´ _#@
Xg#Ø gØP æ´ ø
#Øùw_wwæØ@" dF dP
dØ ¯¯¯ J@ J#
¸Ø´ ¸w-mw_ -g#^^-g#9^ ,a*ww_ _æw,¸wwp
Æ´ _¥" §# ,#F ,#F ,/ #b ¬g#b°"¬²
Æ" Ø __wÆ" ØF ØF ,P _wæP" _#P
_wæwwww@ ÍL ^"¯ ØK ØK ØL·°" ÆF
¡#_ __ض#µww____òm ]#, _w d#_ d@_ ¶#_ _w JP
¬@*#P" "9**@P° °M*Æ" #° @° °M#P¯ *
___wwww___ __ww¸
_æ@°"¯¯¬"°°@*mww_ _*" J@"
___ a" w , ¬°¶@*-^°¯ _wd'
dP¯¯7´ _wØ~ æ´ g° w ¯#P
°^+æb*¤"W" _dK _w" dP d@
9_ dF _,mS@ _Ø J# dØ
¬WØÝ*¤" ,# g# __wwa -g#** _ww_ J#´ _a_ _www_ _w¸ ùw_
g#´ ,#´ #¹ wæP" æc ,#F g°¯ ¬# #Ew¤"#F _æ" `#z ¤9#þ*°¶F
,#F ,#þ d# gØ° dP ØP d" °9 ØP" d@ ,@ _æM° _Ø@"
,#@ ¸#Ø ## dØ _dØ ØP z# dØ JH #F *°" ÆP
,## Ø#F ## # _w##¹ dØ |# g JH´ ,#´_ #L _ ,@
J##F Ø## ##w_w° ¬#Ñ*°¯#@~ jH*" ¶#ææ°¯ aHF #@°¯ ¬MWææ°¯ ,# V1.0
""¯
is just for you.
So what the heck is LetterMatcher ?
-----------------------------------
LetterMatcher lets you create character representations of bitmap images.
This way, you can design your logos in any paint program and have them
converted to ascii text output. There are some programs that do this by
using Amigas own ansi-sequences and building the image row by row but
LetterMatcher creates ordinary ascii output, and even 7-bit if you want it.
Some other novelty uses for LetterMatcher might be:
- Make those wacky ``if you take a step back you can just make out the
face of Queen Elizabeth II from this mess of characters'' pictures
- Make large graphical banners with your text-only printer
- Design IBM-character menus (for your BBS) in a paint program
(if you really want to abuse LetterMatcher)
How to use LetterMatcher
------------------------
For a quick list of available options you can type 'LetterMatcher' in your
CLI. LetterMatcher is a CLI only utility, no other interface is currently
provided.
Currently the source bitmap must be in raw format. Use any available iff
to raw converter to get raw bitmap data from your iff pictures.
The source image must also be one bitplane deep (2 colors) as must be the
source raw bitmap you pass to LetterMatcher.
The command line syntax is:
LetterMatcher [-stmlq] OutName Picture Width Height [FontRange [FontName]]
Where:
Outname <filename, can be inserted in quotes like "File Name">
is the name of the output text file created from your Picture.
Picture <filename, can be inserted in quotes like "File Name">
is the source raw bitmap data file.
Width <integer value, must be divisible by 8>
is the width of your picture in pixels (max 2048). The width of your
picture MUST be divisible by 8, otherwise LetterMatcher will complain. If
you specify a wrong value for the width (other than the original width of
your picture) you get screwy output (slantig horizontal lines).
Height <integer value, divisible by 8>
is the number of lines to convert from your Picture. If you specify the
full height of your source Picture or greater, the whole Picture is
converted. Note that this also should be divisible by 8. Height is always
rounded downwards to the nearest number divisible by 8.
FontRange <byte values, separated with commas ',' or minuses '-'>
specifies the characters to use for matching in your font. The default
FontRange is 32-126,160-254 which gives you all the printable characters in
topaz.font. The example FontRange 3-6,21,32-126,128-254 makes it possible
for your output to contain the characters 3-6,21,32-126,128-254 and not the
characters 0-2,7-20,22-31,127,255.
FontName <name of font with the .font suffix>
specifies the font to use for matching. The font must be 8 pixels wide and
8 pixels high and it must be nonproportional. This makes it possible to
use your olde topaz and the many ibm-style fonts that come with comms
packages. Default is the topaz.font.
-s <a switch, if it is in the command line it is on>
Strip trailing spaces from your output.
-t <a switch, if it is in the command line it is on>
Display the time elapsed while matching your picture in EClock ticks.
-m <a switch, if it is in the command line it is on>
Add a CR/LF pair after each output line. If this switch is not in the
command line only LF is added. CR/LF is usefull for printing purposes.
-l <a switch, if it is in the command line it is on>
Loose matching of characters. This gives you a slightly different output
and is about twice as fast as the normal matching. Sometimes the output
with this switch can even look better.
-q <a switch, if it is in the command line it is on>
Suppress any CLI output but error messages. If this switch is in the
command line no matching information is outputted to your CLI. Note that
timing information is still printed, if the switch -t is on.
OutName, Picture, Width and Height MUST be provided in the command line.
The switches -stmlq are optional. The switches and options MUST be in the
order specified in the command line syntax above. FontRange and FontName
are also optional and if you want to specify a FontName you MUST also
specify a FontRange.
Theory of operation
-------------------
Each 8x8 rectangle of the source bitmap is matched with all of the defined
characters in the font. The character that has the highest number of
matching pixels is displayed in the resulting output.
Currently the program runs somewhat slowly, and I've tried to speed it up
as much as I could. The innermost loop is unrolled for maximum speed under
68000 making the loop 566 bytes in size. Sorry for the 256 byte cache
owners. You can roll these loops tight again.
After all, the number of matches to make for a single picture is quite
large (example picture 640x400):
source rectangle 8x8 pixels = 64 pixels
target rectangle 8x8 pixels = 64 pixels
number of font characters = 256
picture width in characters = 640/8 = 80
picture height in characters = 400/8 = 50
total source rectangles = 80x50 = 4000
to match with 256 target rectangles of 64 pixels each
so in total 64*4000*256 = 65536000 pixel matchings
The work load is made smaller by matching totals of 32+32 pixels in each
iteration thus making it down to 1024000 matches.
I'm sure there is a better and quicker way to do this with a smaller amount
of pixels to match, but this is how I've done it. Of course, some
optimizations are made. If a perfect match for an 8x8 area is found no
more characters are matched. This boosts up the matching speed of pictures
that have a lot of empty spaces in them tremendously.
The more loose matching method works by or'ing the matching pixels of the
upper 4x8 and lower 4x8 areas of the source and the target and then
counting the matching pixels. Giving a pretty good approximation of the
number of matching pixels in each 8x8 rectangle.
Of course, using a smaller font range will speed up the matching.
Fiddling with the result
------------------------
The obvious thing to try is to generate a different output with the -l
switch on.
Another thing to try is to change the x- and y-offsets of your source
bitmap. Since the matching is done in 8x8 rectangles you have 64 possible
starting offsets for your bitmap. Each of these produces a different
output. A clarifying illustration of this follows:
1 2 3 4 5 6 7 8
+-+-+-+-+-+-+-+-+
1: : : : : : : : : :
+-+-+-+-+-+-+-+-+ :
2: : : : : : : : : :
+-+-+-+-+-+-+-+-+ :
3: : : : : : : : : V
+-+-+-+-+-+-+-+-+
4: : : : :X:X:X:X: y-offset
+-+-+-+-+-+-+-+-+
5: : : : :X: : : :
+-+-+-+-+-+-+-+-+
6: : : : :X: : : :
+-+-+-+-+-+-+-+-+
7: : : : :X: : : :
+-+-+-+-+-+-+-+-+
8: : : : :X: : : :
+-+-+-+-+-+-+-+-+
------> x-offset
The Disclaimer
--------------
If this program eats your dog or blows up your hard drive, I'm not in
any way responsible. (no, I'm not responsible for any other kind of
damage you may acquire whilst using this program)
The Author
----------
This particularly magnificent piece of coding was done by Henri Veisterä.
Version 1.0 was finished some time in August 1993. You can leave me e-mail
at hveister@niksula.hut.fi if you have some comments or suggestions to
make. There are no bugs in this program =).
Distribution
------------
LetterMatcher is PD. Do whit it what ever you want. If you want to
distribute modified versions of LetterMatcher indicate somewhere in the
distribution that it is a modified version.
For instance, loading of iff-pictures should be trivial to add if you
already have the code ready, or use an external library.